// 封装的防抖函数
export default function debounce(fn, delay = 200) {
  let timer = null; // 计时器
  return function () {
    const th = this;
    const args = arguments;

    if (timer) {
      clearTimeout(timer);
    }

    timer = setTimeout(function () {
      timer = null;
      fn.apply(th, args);
    }, delay);
  };
}
